package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.CashListModel;
import com.banshuibao.bsb_android.util.PriceUtil;
import com.banshuibao.bsb_android.util.TextPaintUtils;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by Administrator on 2017/12/20.
 */

public class CashListAdapter extends MineBaseAdapter<CashListModel.DataBean>{

    private Context context;

    public CashListAdapter(Context context, List<CashListModel.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
        this.context = context;
    }

    @Override
    protected void bindData(ViewHolder holder, CashListModel.DataBean item) {
        TextView date = (TextView) holder.getView(R.id.date);
        TextView money = (TextView) holder.getView(R.id.money);
        TextView status_tx = (TextView) holder.getView(R.id.status);
        TextPaintUtils.textMothed(money);
        money.setText(PriceUtil.FormatDecimal(item.getMoney()));
        String time = null;
        if (item.getCreateDate() != 0) {
            time = TimeUtil.format(item.getCreateDate());
        } else {
            time = "";
        }
        date.setText(time);
        String status = item.getStatus();
        String reason = item.getReason();
        status_tx.setText(reason);
        if (status.equals("0")){
            status_tx.setTextColor(context.getResources().getColor(R.color.text_default));
        }else if (status.equals("1")){
            status_tx.setTextColor(context.getResources().getColor(R.color.tag_color));
        }else if (status.equals("2")){
            status_tx.setTextColor(context.getResources().getColor(R.color.withdraw_color));
        }
    }
}
